home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 701-725 / 708 / intuisup / intuisup42.lha / Intuisup / source.lha / Editor / main.c < prev    next >
C/C++ Source or Header  |  1992-04-21  |  5KB  |  191 lines

  1. /* $Revision Header *** Header built automatically - do not edit! ***********
  2.  *
  3.  *    (C) Copyright 1991 by Torsten Jürgeleit
  4.  *
  5.  *    Name .....: main.c
  6.  *    Created ..: Sunday 22-Dec-91 21:22:47
  7.  *    Revision .: 0
  8.  *
  9.  *    Date        Author                 Comment
  10.  *    =========   ====================   ====================
  11.  *    22-Dec-91   Torsten Jürgeleit      Created this file!
  12.  *
  13.  ****************************************************************************
  14.  *
  15.  *    Main part
  16.  *
  17.  * $Revision Header ********************************************************/
  18.  
  19.     /* Includes */
  20.  
  21. #include "includes.h"
  22. #include "defines.h"
  23. #include "imports.h"
  24. #include "protos.h"
  25.  
  26.     /* Globals */
  27.  
  28. struct IntuitionBase    *IntuitionBase;
  29. struct GfxBase        *GfxBase;
  30. struct ArpBase        *ArpBase;
  31. struct Library        *IntuiSupBase = NULL;   /* Clear for show_error() */
  32. /*
  33. struct Library        *DiskfontBase;
  34. struct Library        *LayersBase;
  35. */
  36.  
  37. struct Screen        wb_screen;
  38. struct Window        *ewin, *pwin;
  39. struct TextAttr        topaz60_attr = { (STRPTR)"topaz.font", TOPAZ_SIXTY,
  40.                            FS_NORMAL, FPF_ROMFONT },
  41.             topaz80_attr = { (STRPTR)"topaz.font", TOPAZ_EIGHTY,
  42.                            FS_NORMAL, FPF_ROMFONT };
  43. STATIC struct NewWindow  editor_new_window = {
  44.    EDITOR_WINDOW_LEFT, EDITOR_WINDOW_TOP, EDITOR_WINDOW_WIDTH,
  45.    EDITOR_WINDOW_HEIGHT, EDITOR_WINDOW_DETAIL_PEN, EDITOR_WINDOW_BLOCK_PEN,
  46.    EDITOR_WINDOW_IDCMP, EDITOR_WINDOW_FLAGS, NULL, NULL,
  47.    (UBYTE *)&editor_window_title[0], NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN
  48. };
  49. struct NewWindow    project_new_window = {
  50.    0, 0, 0, 0, PROJECT_WINDOW_DETAIL_PEN, PROJECT_WINDOW_BLOCK_PEN,
  51.    PROJECT_WINDOW_IDCMP, PROJECT_WINDOW_FLAGS, NULL, NULL,
  52.    PROJECT_WINDOW_TITLE, NULL, NULL, PROJECT_WINDOW_MIN_WIDTH,
  53.    PROJECT_WINDOW_MIN_HEIGHT, -1, -1, WBENCHSCREEN
  54. };
  55.  
  56. struct TemplateList    template_list;
  57. struct Template        *selected_template,
  58.             *info_template;
  59. struct Box        current_box;
  60.  
  61. struct GadgetData    *use_gd;
  62. struct FileRequester    *project_file_requester,
  63.             *csource_file_requester;
  64.  
  65. struct Dimension    min_dimension[MAX_TEMPLATE_TYPES] = {
  66.     { 20, 10 }, { 0, 0 }, { 20, 10 }, { 21, 11 }, { 50, 10 }, { 30, 8 },
  67.     { 30, 8 }, { 20, 8 }, { 20, 8 }, { 50, 10 }, { 40, 10 },
  68.     { 40, 30 }, { 60, 30 } };
  69.  
  70. APTR    eri, pri, egl, eml, use_gl;
  71.  
  72. BYTE    *default_mx_text_array[] = { "MX1", "MX2", NULL },
  73.     *default_cycle_text_array[] = { "Cycle", "Test 1", "Test 2", NULL },
  74.     *default_listview_text_array[] = { "Entry 1", "Entry 2", "Entry 3",
  75.              "Entry 4", "Entry 5", "Entry 6", "Entry 7", "Entry 8",
  76.                        "Entry 9", "Entry 10", NULL };
  77. BYTE    editor_window_title[MAX_PROJECT_NAME_LEN + 3],
  78.     project_window_title[80];
  79.  
  80. USHORT    snap_offset_table[] = { 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 };
  81.  
  82. USHORT    editor_mode = DEFAULT_EDITOR_MODE,
  83.     snap_offset = DEFAULT_SNAP_OFFSET,
  84.     template_type = DEFAULT_TEMPLATE_TYPE;
  85.  
  86. USHORT    modify_mode = 0, mouse_button = 0;
  87. SHORT    last_snap_x, last_snap_y;
  88.  
  89. BOOL    info_displayed = FALSE;
  90.  
  91.     /* Main routine */
  92.  
  93.    LONG
  94. main(VOID)
  95. {
  96.    LONG return_code = RETURN_ERROR;
  97.  
  98.    MWInit((BPTR)NULL, (LONG)MWF_NOATRASH);
  99.    if (IntuitionBase = OpenLibrary("intuition.library", 0L)) {
  100.       if (GfxBase = OpenLibrary("graphics.library", 0L)) {
  101.      if (!(ArpBase = OpenLibrary(ArpName, ArpVersion))) {
  102.         show_error(EDITOR_ERROR_NO_ARP);
  103.      } else {
  104.         if (!(IntuiSupBase = OpenLibrary(IntuiSupName,
  105.                             IntuiSupVersion))) {
  106.            show_error(EDITOR_ERROR_NO_INTUISUP);
  107.         } else {
  108. /*
  109. if (DiskfontBase = OpenLibrary("diskfont.library", 0L)) {
  110.    if (LayersBase = OpenLibrary("layers.library", 0L)) {
  111. */
  112.            return_code = init_resources();
  113. /*
  114.       CloseLibrary(LayersBase);
  115.    }
  116.    CloseLibrary(DiskfontBase);
  117. }
  118. */
  119.            CloseLibrary(IntuiSupBase);
  120.         }
  121.         CloseLibrary(ArpBase);
  122.      }
  123.      CloseLibrary(GfxBase);
  124.       }
  125.       CloseLibrary(IntuitionBase);
  126.    }
  127.    MWTerm();
  128.    return(return_code);
  129. }
  130.     /* Init resources */
  131.  
  132.    LONG
  133. init_resources(VOID)
  134. {
  135.    SHORT status;
  136.    LONG  return_code = RETURN_OK;
  137.  
  138.    GetScreenData((BYTE *)&wb_screen, (LONG)sizeof(struct Screen), (LONG)
  139.                        WBENCHSCREEN, (struct Screen *)NULL);
  140.    /* Init and open editor window */
  141.    if (!(eri = IGetRenderInfo((struct Screen *)NULL,
  142.                          EDIT_RENDER_INFO_FLAGS))) {
  143.       status = EDITOR_ERROR_OUT_OF_MEM;
  144.    } else {
  145.       editor_new_window.LeftEdge = (wb_screen.Width -
  146.                            editor_new_window.Width) / 2;
  147.       if (!(ewin = IOpenWindow(eri, &editor_new_window,
  148.                          EDIT_OPEN_WINDOW_FLAGS))) {
  149.      status = EDITOR_ERROR_NO_WINDOW;
  150.       } else {
  151.  
  152.      /* Init and open project window */
  153.      pri  = NULL;
  154.      pwin = NULL;
  155.      if ((status = new_project_window(&template_list,
  156.           TEMPLATE_LIST_FLAG_DEFAULT_WINDOW)) == EDITOR_STATUS_NORMAL) {
  157.  
  158.         /* Init ARP file requester structs */
  159.         if (!(project_file_requester = ArpAllocFreq())) {
  160.            status = EDITOR_ERROR_OUT_OF_MEM;
  161.         } else {
  162.            if (!(csource_file_requester = ArpAllocFreq())) {
  163.           status = EDITOR_ERROR_OUT_OF_MEM;
  164.            } else {
  165.           status = editor_action_loop();
  166.            }
  167.         }
  168.      }
  169.  
  170.      /* Free resources */
  171.      if (pwin) {
  172.         ICloseWindow(pwin, FALSE);
  173.         pwin = NULL;
  174.      }
  175.      if (pri) {
  176.         IFreeRenderInfo(pri);
  177.         pri = NULL;
  178.      }
  179.      ICloseWindow(ewin, FALSE);
  180.      ewin = NULL;
  181.       }
  182.       IFreeRenderInfo(eri);
  183.       eri = NULL;
  184.    }
  185.    if (status < EDITOR_STATUS_NORMAL) {
  186.       show_error(status);
  187.       return_code = RETURN_ERROR;
  188.    }
  189.    return(return_code);
  190. }
  191.